package com.lenovo.wxtoken.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
public class ResultBean<T> implements Serializable{

    public static final int SUCCESS = 0;
    public static final int NULL = 1;
    public static final int FAIL = 2;
    public static final int NO_PERMISSION = 3;

    private int errCode = SUCCESS;
    private T result;
    private String errMsg = "success";
    private String expire;

    public ResultBean(T data) {
        super();
        if (data == null){
            this.errCode = NULL;
            this.errMsg = "结果为空";
        } else {
            this.result = data;
        }
    }

    public ResultBean(T data, String expire) {
        super();
        if (data == null){
            this.errCode = NULL;
            this.errMsg = "结果为空";
        } else {
            this.result = data;
            this.expire = expire;
        }
    }

    public ResultBean(Throwable e) {
        super();
        this.errCode = FAIL;
        this.errMsg = e.getMessage();
    }

}
